﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Taobao.Top.Api.Domain;
using Taobao.Top.Api.Request;
using Taobao.Top.Api;

namespace TopHelper
{
    public class Common
    {
        public static TopXmlRestClient CreateTopClient()
        {
            TopXmlRestClient topClient = new TopXmlRestClient("http://gw.api.taobao.com/router/rest", "12112146", "700e662db955b091e73192b4c2837242");
            return topClient;
        }
        public static long GetRateCount(string sessionKey)
        {
            TopXmlRestClient topClient = CreateTopClient();
            TraderatesGetRequest rateReq = new TraderatesGetRequest();
            rateReq.PageSize = 5;
            rateReq.RateType = "get";
            rateReq.Role = "buyer";
            rateReq.Fields = "tid";
            PageList<TradeRate> rateRsp = topClient.TraderatesGet(rateReq, sessionKey);
            long count = rateRsp.TotalResults;
            return count;
        }
    }
}
